﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Web;

namespace zyc
{


    public class M
    {
        public M()
        {
            Console.WriteLine("类M被创建");
        }
        ~M()
        {
            Console.WriteLine("类M被释放");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

            //var list = new List<int>() { 12345, 54321, 9876, 6789, 7654, 4567 };
            //var str = string.Join("--", list);

            //Console.WriteLine(str);

            //Console.WriteLine(5%3);
            //Console.WriteLine(5/3);
            //Console.WriteLine(1%1);
            //Console.WriteLine(1/1);
            //int count = 5;
            //Console.WriteLine(count+=1);


            //var sw = new Stopwatch();
            //Parallel.Invoke();
           
            //Parallel.For(0, 100, item =>
            //{
            //    Console.WriteLine(item+"\t");
            //});
            //for(int i=0;i<100;i++)
            //{
            //    Console.WriteLine(i+"\t");
            //}

            //using (Destructor d = new Destructor())
            //{
            //    Console.WriteLine("调用d 处理逻辑");
            //}

            //var list =new List<int>(){1,2,3,4,5,6,7,8,9,0};
            //Console.WriteLine( "打印偶数：");
            //foreach (var item in list)
            //{
                
            //    if (item%2 == 0)
            //    {
            //        Console.WriteLine( item+"|");
            //    }
            //}
            //Console.WriteLine( "打印奇数");
            //foreach (var item in list)
            //{
            //    if (item%2 == 1)
            //    {
            //        Console.WriteLine( item+"|");
            //    }
            //}

            //Publisher magazin = new Publisher();
            //Subcriber zs = new Subcriber("张三");
            //Subcriber WW = new Subcriber("王五");
            //Subcriber LS = new Subcriber("李四");
            //Subcriber ML = new Subcriber("马六");
            //magazin.PublishMagazine += zs.Receive;
            //magazin.PublishMagazine += WW.Receive;
            //magazin.PublishMagazine += LS.Receive;
            //magazin.PublishMagazine += ML.Receive;
            //magazin.PublisIssue("电脑", DateTime.Now);
            //magazin.PublishMagazine -= WW.Receive;
            //magazin.PublisIssue("电子", DateTime.Now);
            //d.Dispose();

            //new M();
            ////GC.Collect(); //手动回收
            //new M();
            //new M();
            //new M();
            List<Every> result = new List<Every>();
 
            Type enumType = typeof (CustonEnum.NumberEnum);
            if (enumType.IsEnum == false) { result= null; }
            var typeDescription = typeof(DescriptionAttribute);
            var fields = enumType.GetFields().Where(a=>!a.IsSpecialName).ToList();
            foreach (var field in fields.Where(field => !field.IsSpecialName))
            {
                var strValue = field.Name;
                var arr = field.GetCustomAttributes(typeDescription, true);
                var strText = arr.Length > 0 ? ((DescriptionAttribute)arr[0]).Description : field.Name;
                result.Add(new Every(){Text = strText,Value = strValue});
            }

            Console.ReadLine();
            Console.Read();
        }
    }

    public class Every
    {
        public string  Text { get; set; }
        public string  Value { get; set; }
    }

    public class CustonEnum
    {
        public enum NumberEnum
        {
            /// <summary>
            /// 第一
            /// </summary>
            [Description("第一个数")]
            One,
            /// <summary>
            /// 第二
            /// </summary>
            [Description("第二个数")]
            Two,
            /// <summary>
            ///第三 
            /// </summary>
            [Description("第三个数")]
            Three,
            /// <summary>
            /// 第四
            /// </summary>
            [Description("第四个数")]
            Four,
            /// <summary>
            /// 第五
            /// </summary>
            [Description("第五个数")]
            Five

        }

    }
}
